import Vue from 'vue'
import VueRouter from 'vue-router'
import routerBeforeEach from './beforeEach'
import {
  LoadLayOut,
  LoadLoginIndex,
  LoadLoginSignUp,
  LoadLoginSignIn,
  LoadHome,
  LoadCategory,
  LoadProfile,
  LoadPublish,
  LoadUserInfo,
  LoadSave,
  LoadSupport,
  LoadMyArticle,
  LoadList,
  LoadArticleShow
} from './load'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: 'layout'
  },
  {
    path: '/layout',
    name: 'layout',
    component: LoadLayOut,
    redirect: { name: 'home' },
    children: [
      {
        name: 'home',
        path: 'home',
        component: LoadHome
      },
      {
        name: 'category',
        path: 'category',
        component: LoadCategory
      },
      {
        name: 'publish',
        path: 'publish',
        component: LoadPublish
      },
      {
        name: 'profile',
        path: 'profile',
        component: LoadProfile
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    redirect: '/login/signin',
    component: LoadLoginIndex,
    children: [
      {
        name: 'signin',
        path: 'signin',
        component: LoadLoginSignIn
      },
      {
        name: 'signup',
        path: 'signup',
        component: LoadLoginSignUp
      }
    ]
  },
  {
    name: 'userinfo',
    path: '/userinfo',
    component: LoadUserInfo
  },
  {
    name: 'save',
    path: '/profile/save',
    component: LoadSave
  },
  {
    name: 'support',
    path: '/profile/support',
    component: LoadSupport
  },
  {
    name: 'list',
    path: '/cate/list',
    component: LoadList
  },
  {
    name: 'articleshow',
    path: '/article/articleshow',
    component: LoadArticleShow
  },
  {
    name: 'myarticle',
    path: '/profile/myarticle',
    component: LoadMyArticle
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})
routerBeforeEach(router)
export default router
